﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Text;

namespace DbSetupHelper.Common
{
    /// <summary>
    /// Class used to hold information about the currently running install.
    /// </summary>
    public class InstallParameters
    {
        private string user;
        private string password;
        private string server;
        private bool testInstall;
        private bool showHelp;
        private bool interactiveInstall = true; //default to interactive install.
        private bool debugMode;
        private bool extractOnly;
        private bool cancelInstall;
        private Collection<DBScript> scriptPattern;
        private string dbName;
        private string dbUserName;
        private string dbUserPassword;
        private string extractDirectory;
        private Assembly scriptPackageAssembly;

        public InstallParameters Clone()
        {
            InstallParameters retValue = new InstallParameters();

            retValue.CancelInstall = cancelInstall;
            retValue.DbName = dbName;
            retValue.DbUserName = dbUserName;
            retValue.DbUserPassword = dbUserPassword;
            retValue.DebugMode = debugMode;
            retValue.ExtractDirectory = extractDirectory;
            retValue.ExtractOnly = extractOnly;
            retValue.InteractiveInstall = interactiveInstall;
            retValue.Password = password;
            retValue.ScriptPackageAssembly = scriptPackageAssembly;

            retValue.ScriptPattern = new Collection<DBScript>();
            foreach (DBScript script in scriptPattern)
                retValue.ScriptPattern.Add(script.Clone());

            retValue.Server = server;
            retValue.ShowHelp = showHelp;
            retValue.TestInstall = testInstall;
            retValue.User = user;

            return retValue;
        }

        /// <summary>
        /// Gets or sets the user.
        /// </summary>
        /// <value>The user.</value>
        public string User
        {
            get { return this.user; }
            set { this.user = value; }
        }

        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>The password.</value>
        public string Password
        {
            get { return this.password; }
            set { this.password = value; }
        }

        /// <summary>
        /// Gets or sets the server path.
        /// </summary>
        /// <value>The server path.</value>
        public string Server
        {
            get { return this.server; }
            set { this.server = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [test install].
        /// </summary>
        /// <value><c>true</c> if [test install]; otherwise, <c>false</c>.</value>
        public bool TestInstall
        {
            get { return this.testInstall; }
            set { this.testInstall = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [show help].
        /// </summary>
        /// <value><c>true</c> if [show help]; otherwise, <c>false</c>.</value>
        public bool ShowHelp
        {
            get { return this.showHelp; }
            set { this.showHelp = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [interactive install].
        /// </summary>
        /// <value><c>true</c> if [interactive install]; otherwise, <c>false</c>.</value>
        public bool InteractiveInstall
        {
            get { return this.interactiveInstall; }
            set { this.interactiveInstall = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [debug mode].
        /// </summary>
        /// <value><c>true</c> if [debug mode]; otherwise, <c>false</c>.</value>
        public bool DebugMode
        {
            get { return this.debugMode; }
            set { this.debugMode = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [extract only].
        /// </summary>
        /// <value><c>true</c> if [extract only]; otherwise, <c>false</c>.</value>
        public bool ExtractOnly
        {
            get { return this.extractOnly; }
            set { this.extractOnly = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [cancel install].
        /// </summary>
        /// <value><c>true</c> if [cancel install]; otherwise, <c>false</c>.</value>
        public bool CancelInstall
        {
            get { return this.cancelInstall; }
            set { this.cancelInstall = value; }
        }

        /// <summary>
        /// Gets or sets the script pattern.
        /// </summary>
        /// <value>The script pattern.</value>
        public Collection<DBScript> ScriptPattern
        {
            get { return this.scriptPattern; }
            set { this.scriptPattern = value; }
        }

        /// <summary>
        /// Gets or sets the name of the db.
        /// </summary>
        /// <value>The name of the db.</value>
        public string DbName
        {
            get { return this.dbName; }
            set { this.dbName = value; }
        }

        /// <summary>
        /// Gets or sets the name of the db user.
        /// </summary>
        /// <value>The name of the db user.</value>
        public string DbUserName
        {
            get { return this.dbUserName; }
            set { this.dbUserName = value; }
        }

        /// <summary>
        /// Gets or sets the db user password.
        /// </summary>
        /// <value>The db user password.</value>
        public string DbUserPassword
        {
            get { return this.dbUserPassword; }
            set { this.dbUserPassword = value; }
        }

        /// <summary>
        /// Gets the extract directory.
        /// </summary>
        /// <value>The extract directory.</value>
        public string ExtractDirectory
        {
            get { return extractDirectory; }
            set { extractDirectory = value; }
        }

        /// <summary>
        /// Gets or sets the script package assembly.
        /// </summary>
        /// <value>The script package assembly.</value>
        public Assembly ScriptPackageAssembly
        {
            get { return scriptPackageAssembly; }
            set { scriptPackageAssembly = value; }
        }
    }
}
